
#include "particle.h"
#include "util.h"
#include "object.h"

void Particle::init(float life){
	destroy = false;
	lifespan = life;
	lastPos = Vector4();
}
Particle::Particle(float life) : Object()
{
	init(life);
}
Particle::Particle(float life, float x, float y, float z) : Object(x,y,z)
{
	init(life);
}
Particle::Particle(float life,
				   float x, float y, float z,
				   float dx,float dy,float dz) : Object(x,y,z, dx,dy,dz)
{
	destroy = false;
	init(life);
}

void Particle::translateXYZ(float x, float y, float z){
	lastPos = pos;
	Object::translateXYZ(x,y,z);
	
}
bool Particle::update(float etime)
{
	lifespan -= etime;
	if (lifespan < 0.f) return false;

	//Object::update(etime);
	Vector4 emptyPos = Vector4();
	EulerInt(emptyPos, vel, acc, etime);
	translateXYZ(emptyPos[0], emptyPos[1], emptyPos[2]);
	//if (pos(1) < -10.f) return false;
	//if (pos(0) >= 50.f || pos(0) <= -50.f) return false;
	//if (pos(2) >= 50.f || pos(0) <= -50.f) return false;
	
	return true;
}

Particle::~Particle(void)
{
}
